from decimal import Decimal

from pydantic import BaseModel, ConfigDict, Field


class FileInfoVo(BaseModel):
    """文件信息"""
    file_id: int = Field(..., alias="fileId", description="文件id")
    file_name: str = Field(..., alias="fileName", description="名称")
    file_path: str = Field(..., alias="filePath", description="路径")
    file_size: int = Field(..., alias="fileSize", description="文件大小")
    file_type: int = Field(..., alias="fileType", description="文件类型")
    file_ext: str = Field(..., alias="fileExt", description="扩展名")
    preview_url: str = Field(..., alias="previewUrl", description="预览链接")
    external_url: str = Field(..., alias="externalUrl", description="扩展链接")

    model_config = ConfigDict(
        # 允许 SQLAlchemy ORM 对象直接转模型
        from_attributes=True,
        extra="ignore",
        # 如果数据库返回 Decimal 自动转 float
        json_encoders={Decimal: float},
    )
